import { transformTime1 } from '@/utils/util'

export const transNewSonglist = (res) => {
  const { data: { data } } = res
  if (res && data && data.length) {
    return data.map(item => {
      const { id, name, mvid, exclusive, duration, album: { alias: alAlias, name: alName, id: alId, picUrl }, alias, artists: list } = item
      const artists = list.map(item => ({ id: item.id, name: item.name }))
      const durationStr = transformTime1(duration)
      const aliasStr = alias.length ? '(' + alias.join('/') + ')' : ''
      const alAliasStr = alAlias.length ? '(' + alAlias.join('/') + ')' : ''
      return {
        id,
        name,
        mvid,
        exclusive,
        durationStr,
        alName,
        alId,
        picUrl,
        artists,
        aliasStr,
        alAliasStr
      } as NewSong
    })
  } else {
    return []
  }
}
